import React from 'react'
import jsonArticle from '../../axios/Article.json'
import jsonArticleSuperClub from '../../axios/ArticleSuperClub.json'
import jsonArticleBodyHomePage from '../../axios/ArticleBodyHomePage.json'
export default function Article({ jsonUrl, flag }) {
    let jsonData = []
    // console.log('../axios/' + jsonUrl + '.json');
    switch (jsonUrl) {
        case 'Article': jsonData = jsonArticle; break;
        case 'ArticleBodyHomePage': jsonData = jsonArticleBodyHomePage; break;
        case 'ArticleSuperClub': jsonData = jsonArticleSuperClub; break;
        default: jsonData = jsonArticle; break;
    }
    return (
        <div className="list-group">
            <a className="list-group-item list-group-item-action" href='#'>{flag ? "推荐" : ""}</a>{
                jsonData.data.map((item) => {
                    return <a href={`/ArticleContent/${item.titleID}`} className="list-group-item list-group-item-action">
                        <div>
                            <div>文章名称：{item.title}</div>
                            <div>文章简介：{item.titleBlurb}</div>
                            <div>
                                <span>作者：{item.titleUser}</span>
                                <span>发布时间：{item.titleDate}</span>
                            </div>
                        </div>
                    </a>
                })
            }
            {flag ? <div> <a className="list-group-item list-group-item-action" href="/Article">查看更多文章</a> </div> : <div></div>}
            {/* {console.log(flag)} */}
        </div>
    )
}
